<?php

namespace App\Http\Controllers\Frontend\Dances;

use Illuminate\Http\Request;
use App\Http\Service\frontend\DancesService;
use App\Http\Models\Dances\DancesFrontendFrom;
use App\Http\Controllers\Frontend\ApiController;
use App\Http\Models\Dances\DancesFrontendListFrom;

/**
 * Description of IndexController
 *
 * @author Admin
 */
class IndexController extends ApiController
{

    private $dancesService;

    public function __construct(DancesService $dancesService)
    {
        $this->dancesService = $dancesService;
    }

    //获取课程
    public function index(DancesFrontendListFrom $dancesFrontendListFrom)
    {
        return $this->success($this->dancesService->index($dancesFrontendListFrom));
    }

    //课程预约
    public function subscribeDances(DancesFrontendFrom $dancesFrontendFrom)
    {
        $result = $this->dancesService->subscribeDances($dancesFrontendFrom);
        if ($result['code'] == 200) {
            return $this->success(NOT_DATA, $result['message']);
        }
        return $this->errors(NOT_DATA, $result['message'], $result['code']);
    }

    //课程详情
    public function show($dancesId)
    {
        $result = $this->dancesService->show($dancesId);
        if ($result) {
            return $this->success($result);
        }
        return $this->errors(NOT_DATA, NOT_INFO);
    }

}
